#!/usr/bin/python
# -*- coding: utf-8 -*-

SINGER_LIST_FILE = 'data/singers.txt'
FILE_ENCODING = 'utf-8'
DEFAULT_TYPE = u'團體組合'

HINT_MAPPING = {
    u'國外男歌手': u'男歌手',
    u'大陸男歌手': u'男歌手',
    u'港台男歌手': u'男歌手',
    u'國外女歌手': u'女歌手',
    u'大陸女歌手': u'女歌手',
    u'港台女歌手': u'女歌手',
    }

class SingerDB:
    def __init__(self, config):
        self._config = config
        self._singer_types = {}

        for line in open(SINGER_LIST_FILE, 'r'):
            path = line.decode(FILE_ENCODING).strip()
            if path:
                (singer, singer_type) = path.split(',')
                self._singer_types[singer] = singer_type

    def GetSingerType(self, singer, path_hints):
        if singer in self._singer_types:
            return self._singer_types[singer]

        for c in path_hints:
            if c in HINT_MAPPING:
                return HINT_MAPPING[c]

        return DEFAULT_TYPE
